<html>
<head><meta charset="utf-8"><title>Idea about spawning tasks · wg-async-foundations · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/index.html">wg-async-foundations</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html">Idea about spawning tasks</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="231291349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231291349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Michael (kellerkindt) <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231291349">(Mar 22 2021 at 10:55)</a>:</h4>
<p>This idea just crossed my mind, but the longer I think about it, the more obvious(ly flawed) it looks. So, before I forget to ever mention this anywhere, here is an idea on how  to approach spawning futures without knowing the executor/event loop:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">  </span><span class="c1">// core/task/wake.rs</span>
<span class="w">  </span><span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">Context</span><span class="o">&lt;'</span><span class="na">a</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">      </span><span class="n">waker</span>: <span class="kp">&amp;</span><span class="o">'</span><span class="na">a</span> <span class="nc">Waker</span><span class="p">,</span><span class="w"></span>
<span class="o">+</span><span class="w">     </span><span class="n">runtime</span>: <span class="nb">Option</span><span class="o">&lt;&amp;'</span><span class="na">a</span><span class="w"> </span><span class="n">Runtime</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">      </span><span class="n">_marker</span>: <span class="nc">PhantomData</span><span class="o">&lt;</span><span class="k">fn</span><span class="p">(</span><span class="o">&amp;'</span><span class="na">a</span><span class="w"> </span><span class="p">())</span><span class="w"> </span>-&gt; <span class="kp">&amp;</span><span class="o">'</span><span class="na">a</span> <span class="p">()</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">  </span><span class="p">}</span><span class="w"></span>

<span class="w">  </span><span class="k">impl</span><span class="o">&lt;'</span><span class="na">a</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Context</span><span class="o">&lt;'</span><span class="na">a</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">      </span><span class="k">pub</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="k">fn</span> <span class="nf">from_waker</span><span class="p">(</span><span class="n">waker</span>: <span class="kp">&amp;</span><span class="o">'</span><span class="na">a</span> <span class="nc">Waker</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="o">-</span><span class="w">         </span><span class="n">Context</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">waker</span><span class="p">,</span><span class="w"> </span><span class="n">_marker</span>: <span class="nc">PhantomData</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="o">+</span><span class="w">         </span><span class="n">Context</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">waker</span><span class="p">,</span><span class="w"> </span><span class="n">runtime</span>: <span class="nb">None</span><span class="p">,</span><span class="w"> </span><span class="n">_marker</span>: <span class="nc">PhantomData</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w">      </span><span class="p">}</span><span class="w"></span>

<span class="o">+</span><span class="w">     </span><span class="k">pub</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="k">fn</span> <span class="nf">with_runtime</span><span class="p">(</span><span class="bp">self</span>: <span class="nc">runtime</span>: <span class="nc">Runtime</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="o">+</span><span class="w">         </span><span class="bp">Self</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">waker</span>: <span class="nc">self</span><span class="p">.</span><span class="n">waker</span><span class="p">,</span><span class="w"> </span><span class="n">runtime</span><span class="p">,</span><span class="w"> </span><span class="n">_marker</span>: <span class="nc">PhantomData</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="o">+</span><span class="w">     </span><span class="p">}</span><span class="w"></span>
<span class="o">+</span><span class="w"></span>
<span class="o">+</span><span class="w">     </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">runtime</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nb">Option</span><span class="o">&lt;&amp;'</span><span class="na">a</span><span class="w"> </span><span class="n">Waker</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="o">+</span><span class="w">         </span><span class="bp">self</span><span class="p">.</span><span class="n">runtime</span><span class="w"></span>
<span class="o">+</span><span class="w">     </span><span class="p">}</span><span class="w"></span>
<span class="w">  </span><span class="p">}</span><span class="w"></span>

<span class="c1">// to be implemented by the async library, such as tokio, async-std... (analogue to Waker)</span>
<span class="o">+</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="n">Runtime</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="o">+</span><span class="w">     </span><span class="k">fn</span> <span class="nf">spawn_local</span><span class="o">&lt;</span><span class="n">F</span>: <span class="nc">Future</span><span class="o">&gt;</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">f</span>: <span class="nc">F</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nb">Result</span><span class="o">&lt;</span><span class="p">(),</span><span class="w"> </span><span class="n">SpawnError</span><span class="o">&gt;</span><span class="p">;</span><span class="w"></span>
<span class="o">+</span><span class="w"> </span><span class="p">}</span><span class="w"></span>

<span class="w">  </span><span class="c1">// core/task</span>
<span class="o">+</span><span class="w"> </span><span class="k">struct</span> <span class="nc">SpawnLocal</span><span class="o">&lt;</span><span class="n">F</span>: <span class="nc">Future</span><span class="o">&gt;</span><span class="p">(</span><span class="n">f</span><span class="p">);</span><span class="w"></span>
<span class="o">+</span><span class="w"></span>
<span class="o">+</span><span class="w"> </span><span class="k">impl</span><span class="o">&lt;</span><span class="n">F</span>: <span class="nc">Future</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Future</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">SpawnLocal</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="o">+</span><span class="w">     </span><span class="k">type</span> <span class="nc">Output</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Result</span><span class="o">&lt;</span><span class="p">(),</span><span class="w"> </span><span class="n">SpawnError</span><span class="o">&gt;</span><span class="p">;</span><span class="w"></span>
<span class="o">+</span><span class="w"></span>
<span class="o">+</span><span class="w">     </span><span class="k">fn</span> <span class="nf">poll</span><span class="p">(</span><span class="bp">self</span><span class="w"> </span><span class="n">Pin</span><span class="o">&lt;&amp;</span><span class="k">mut</span><span class="w"> </span><span class="bp">Self</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="n">cx</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="n">Context</span><span class="o">&lt;'</span><span class="nb">_</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Poll</span><span class="o">&lt;</span><span class="bp">Self</span>::<span class="n">Output</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="o">+</span><span class="w">         </span><span class="k">if</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nb">Some</span><span class="p">(</span><span class="n">runtime</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">cx</span><span class="p">.</span><span class="n">runtime</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="o">+</span><span class="w">             </span><span class="n">Poll</span>::<span class="n">Ready</span><span class="p">(</span><span class="n">runtime</span><span class="p">.</span><span class="n">spawn</span><span class="p">(</span><span class="bp">self</span><span class="p">.</span><span class="mi">0</span><span class="p">))</span><span class="w"></span>
<span class="o">+</span><span class="w">         </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="o">+</span><span class="w">             </span><span class="n">Poll</span>::<span class="n">Ready</span><span class="p">(</span><span class="nb">Err</span><span class="p">(</span><span class="n">SpaenError</span>::<span class="n">NoRuntime</span><span class="p">))</span><span class="w"></span>
<span class="o">+</span><span class="w">         </span><span class="p">}</span><span class="w"></span>
<span class="o">+</span><span class="w">     </span><span class="p">}</span><span class="w"></span>
<span class="o">+</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="o">+</span><span class="w"></span>
<span class="o">+</span><span class="w"> </span><span class="k">fn</span> <span class="nf">spawn_local</span><span class="o">&lt;</span><span class="n">F</span>: <span class="nc">Future</span><span class="o">&gt;</span><span class="p">(</span><span class="n">f</span>: <span class="nc">F</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">impl</span><span class="w"> </span><span class="n">Future</span><span class="o">&lt;</span><span class="n">Output</span><span class="o">=</span><span class="w"> </span><span class="nb">Result</span><span class="o">&lt;</span><span class="p">(),</span><span class="w"> </span><span class="n">SpawnError</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="o">+</span><span class="w">   </span><span class="n">SpawnLocal</span><span class="p">(</span><span class="n">f</span><span class="p">).</span><span class="k">await</span><span class="w"></span>
<span class="o">+</span><span class="w"> </span><span class="p">}</span><span class="w"></span>



<span class="c1">// usage</span>

<span class="cp">#[tokio::main]</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">std</span>::<span class="n">task</span>::<span class="n">spawn_local</span><span class="p">(</span><span class="k">async</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="fm">println!</span><span class="p">(</span><span class="s">"Hello from another task"</span><span class="p">)</span><span class="w"></span>
<span class="w">    </span><span class="p">}).</span><span class="k">await</span><span class="p">.</span><span class="n">unwrap</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>(Missing: the spawning should probably return a JoinHandle or something like that...)</p>
<p>The main idea is that async functions of libraries that need to spawn tasks pretty sure want to spawn the new task into the same event loop as they are already running in. By extending <code>Context</code> - which is available in the async fn because of Future::poll - one could provide a way to access the current event-loop without global variables.</p>
<p>In addition to <code>spawn_local</code> - which is based on the naming schema of tokio (<a href="https://docs.rs/tokio/1.4.0/tokio/task/index.html#functions">https://docs.rs/tokio/1.4.0/tokio/task/index.html#functions</a>) - additional functions for the <code>Runtime</code> would be needed. Also, RawRuntimeVTable and its companions.</p>



<a name="231293497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231293497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alice Ryhl <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231293497">(Mar 22 2021 at 11:16)</a>:</h4>
<p>I mean, you can already define the trait and pass it as an ordinary parameter. The actual design of the trait is probably a more significant discussion, e.g. you use <code>spawn_local</code> here, but that's only supported in Tokio when you have set up a <code>LocalSet</code>, which is relatively rare.</p>



<a name="231299314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231299314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Michael (kellerkindt) <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231299314">(Mar 22 2021 at 12:10)</a>:</h4>
<p>Yeah, I chose <code>spawn_local</code> to show that there could be multiple <code>spawn_*</code> functions. I don't follow your point on "pass it as an ordinary parameter". If I understand you correctly, that would mean that the binary author has to pass it to the library and the library to pass it along to everywhere where it might be required? I mean it would work, but it also forces the author of the libs (recursively) to consider and implement it vs just being able to spawn a future/task in the same context when needed - which requires far less implementation work and probably(?) covers most use cases? I think the nice thing about the example above is that the <code>Runtime</code> parameter is passed in through the <code>.await</code> call by the event-loop itself. But maybe I am wrong in my assumption here. Thanks for looking at it at all xD</p>



<a name="231305008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231305008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alice Ryhl <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231305008">(Mar 22 2021 at 12:57)</a>:</h4>
<p>I mean, sure, the above would be more convenient like that, although I will note that spawn methods are typically not async methods, but they would have to be in order to access the data in the context.</p>



<a name="231313254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231313254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231313254">(Mar 22 2021 at 13:53)</a>:</h4>
<p>So, I'm trying to avoid thinking too hard about these sorts of details yet, but I have been assuming that we might add details like this to the <code>Context</code></p>



<a name="231313273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231313273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231313273">(Mar 22 2021 at 13:53)</a>:</h4>
<p>there would be some details to figure out though</p>



<a name="231313322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231313322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231313322">(Mar 22 2021 at 13:54)</a>:</h4>
<p>still, I like the idea of being able to spawn onto "the current executor" without having to know what that is</p>



<a name="231314998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231314998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231314998">(Mar 22 2021 at 14:04)</a>:</h4>
<p>Does the runtime need to be an Option, and stored in the context? Could we have a generic type parameter on the context that provides the runtime, and then a static method to spawn, without needing storage?</p>



<a name="231316453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231316453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Michael (kellerkindt) <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231316453">(Mar 22 2021 at 14:13)</a>:</h4>
<p>I think the <code>Option</code> wrapping is required for it to be backwards compatible. A generic type parameter + static fn is an interesting idea to avoid that, but it would require an global / thread local variable in the implementation and hindering the possibility of having multiple instances of the same event-loop running? A default type would also be needed to be backwards compatible.</p>



<a name="231366884"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231366884" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Patrick Walton <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231366884">(Mar 22 2021 at 19:08)</a>:</h4>
<p>FWIW putting some kind of handle to the executor in the Context is something we've been talking about when it comes to Rust tasks running on C++ executors.</p>



<a name="231441469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231441469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231441469">(Mar 23 2021 at 09:22)</a>:</h4>
<p><span class="user-mention" data-user-id="384014">@Patrick Walton</span> did you ever open an issue or write a story about C++ interop? I think that'd be really interesting to hear more about</p>



<a name="231443277"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231443277" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Michael (kellerkindt) <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231443277">(Mar 23 2021 at 09:40)</a>:</h4>
<p>This <a href="https://github.com/rust-lang/wg-async-foundations/issues/67">issue exists</a></p>



<a name="231464084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231464084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Michael (kellerkindt) <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231464084">(Mar 23 2021 at 12:52)</a>:</h4>
<p>It would be my first but if this seems interesting enough, I would try to write a RFC for that. What do you think? (titled something like "Spawning a future onto the current executor without having to know what that is")</p>



<a name="231466954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231466954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231466954">(Mar 23 2021 at 13:10)</a>:</h4>
<p>Well, my take is that I'd prefer not to be writing RFCs yet. I want to see us working through this vision process before we decide what RFCs to write. Im particularly keen to identify clearly both (a) the stories about what it's like today and (b) a user-oriented story of what experience we want to enable before we worry about the details of how we will achieve it</p>



<a name="231466990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231466990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231466990">(Mar 23 2021 at 13:10)</a>:</h4>
<p>Some thoughts on what that might mean here:</p>



<a name="231467025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231467025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231467025">(Mar 23 2021 at 13:11)</a>:</h4>
<ul>
<li>we want people to be able to write portable libraries that have need of spawning tasks</li>
</ul>



<a name="231467057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231467057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231467057">(Mar 23 2021 at 13:11)</a>:</h4>
<ul>
<li>people need to spawn tasks from various sorts of places, including (it sounds like) Drop impls</li>
</ul>



<a name="231467307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231467307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231467307">(Mar 23 2021 at 13:13)</a>:</h4>
<ul>
<li>people want to be able to compose executors together -- I'd like to dig into this a bit better -- does it happen that the "current executor" is not the one you should spawn onto? when does that occur</li>
</ul>



<a name="231513938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231513938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Patrick Walton <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231513938">(Mar 23 2021 at 17:52)</a>:</h4>
<p>I opened the user story, were you thinking of anything more?</p>



<a name="231514053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231514053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Patrick Walton <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231514053">(Mar 23 2021 at 17:53)</a>:</h4>
<p>Unfortunately, C++ interop is looking like yet another case of "everything is fairly straightforward, except that Rust futures can be dropped at any time and C++ futures cannot, which is causing a lot of problems"</p>



<a name="231526233"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231526233" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231526233">(Mar 23 2021 at 19:10)</a>:</h4>
<p><span class="user-mention" data-user-id="384014">@Patrick Walton</span> what user story did you open?</p>



<a name="231526246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231526246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231526246">(Mar 23 2021 at 19:10)</a>:</h4>
<p>do you mean you opened an issue?</p>



<a name="231526300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231526300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231526300">(Mar 23 2021 at 19:10)</a>:</h4>
<p>I was thinking of a PR ..</p>



<a name="231551501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231551501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Patrick Walton <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231551501">(Mar 23 2021 at 22:06)</a>:</h4>
<p>Yeah</p>



<a name="231551523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/Idea%20about%20spawning%20tasks/near/231551523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Patrick Walton <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/Idea.20about.20spawning.20tasks.html#231551523">(Mar 23 2021 at 22:06)</a>:</h4>
<p>I could do a PR</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>